package com.saw;


import java.util.ArrayList;

public class StudentArrayList {
//    1. 创建学生类
//    创建集合对象


    public static void main(String[] args) {

        ArrayList<Student> array = new ArrayList<Student>();

        Student s1 = new Student("周杰伦", 34);
        Student s2 = new Student("刘德华", 43);
        Student s3 = new Student("陶喆", 56);

//       添加对象
        array.add(s1);
        array.add(s2);
        array.add(s3);
//        遍历
//
        for (int i = 0; i < array.size(); i++) {
            Student s = array.get(i);
            System.out.println(s.getName()+","+ s.getAge());

        }
    }
}
